package com.atguigu.gulimall.auth.oauth;

import org.springframework.stereotype.Component;

/**
 * @author 蔡心怡
 * @version 1.0
 */
@Component
public class GiteeOauth implements BaseOauth {

    private static final String GITEE_CLIENT_ID = "7effe1549ae0b9a81c65eda2c3d78b9f696f9cc2059bc2ae6d092150d918e034";
    private static final String GITEE_CLIENT_SECRET = "3d05e2caedfbf1a62a4de3a3558f9663dcbc891491e10ff43f930f208ab6aac8";

    private static final String REDIRECT_URI = "http://auth.gulimall.com/oauth2.0/gitee/success";

    @Override
    public String authorize() {
        return "https://gitee.com/oauth/authorize?client_id=" + GITEE_CLIENT_ID + "&response_type=code&redirect_uri=" + REDIRECT_URI;
    }

    @Override
    public String accessToken(String code) {
        return "https://gitee.com/oauth/token?grant_type=authorization_code&code=" + code + "&client_id=" + GITEE_CLIENT_ID + "&redirect_uri=" + REDIRECT_URI + "&client_secret=" + GITEE_CLIENT_SECRET;
    }

    @Override
    public String userInfo(String accessToken) {
        return "https://gitee.com/api/v5/user?access_token=" + accessToken;
    }
}

